package com.bayihouse.model.excel.publicClass;

import com.baomidou.mybatisplus.annotation.TableField;
import com.bayihouse.model.excel.publicClass.father.BaseEntity;
import com.bayihouse.utils.MyObjectUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@AllArgsConstructor
@NoArgsConstructor
@Data
public abstract class BaseFatherOneEntity<T> extends BaseEntity {

    @TableField(exist = false)
    protected T father;

    @TableField(exist = false)
    protected List<T> childrenList;

    protected boolean checkIsEmptyCList() {
        if (super.id == null) {
            return true;
        }
        if (MyObjectUtils.isArraysEmpty(childrenList)) {
            return true;
        }
        return false;
    }

    protected boolean checkIsEmptyF() {
        if (super.id == null) {
            return true;
        }
        if (MyObjectUtils.isNull(father)) {
            return true;
        }
        return false;
    }


    public void initT() {
        childrenList = new ArrayList<>();
    }

    protected abstract void setFId();

    protected abstract void setCId();





}
